package models

import (
	"galaxy-manage/internal/code"
	"github.com/gin-gonic/gin"
	"net/http"
)

type PageResult[T any] struct {
	Code string  `json:"code"`
	Msg  string  `json:"msg"`
	Data Data[T] `json:"data"`
}

type Data[T any] struct {
	Total int64
	List  []T
}

func PageSuccess[T any](Ctx *gin.Context, total int64, list []T) {
	Ctx.JSON(http.StatusOK, Result[any]{
		Code: code.OK.Code,
		Msg:  code.OK.Message,
		Data: list,
	})

}
